<template>
  <div class="content">
    <div class="content-main">
      <div class="list-wrap">
        <div
          class="list-info"
          v-for="(item, index) in infoList"
          :key="index"
          @click="jumpPage(item)"
        >
          <!-- <div>
            <img
              :src="item.articlePicture"
              style="width: 180px; height: 120px; margin-right: 20px"
              alt=""
            />
          </div> -->
          <div style="width: 100%">
            <div class="list-info-title">{{ item.title }}</div>
            <div class="list-info-content">
              <span class="list-info-info">{{ item.articleAbstract }}</span>
            </div>
          </div>
        </div>
        <div class="pagination">
          <el-pagination
            layout="prev, pager, next"
            :total="queryParams.total"
            @current-change="currentChange"
          />
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { cmsArticle } from '@/api'
import { View } from '@element-plus/icons-vue'
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
const queryParams = reactive({
  name: '',
  pageNum: 1,
  pageSize: 10,
  total: 0
})
const infoList = ref([])
const router = useRouter()
function jumpPage(item) {
  router.push({ path: 'newsDetails', query: { id: item.id } })
}
function currentChange(val) {
  queryParams.pageNum = val
  getList()
}
function getList() {
  cmsArticle({
    pageNum: queryParams.pageNum,
    pageSize: queryParams.pageSize,
    articleType$Contains: 'NS' //科普知识
  }).then(({ data }) => {
    queryParams.total = data.total
    infoList.value = data.list
  })
}
onMounted(() => {
  getList()
})
</script>
<style lang="scss" scoped>
.content {
  background-color: #f6faff;
  padding-top: 20px;
}

.content-main {
  width: 1200px;
  min-height: 850px;
  margin: auto;

  .list-wrap {
    .list-info {
      display: flex;
      align-items: center;
      margin-bottom: 20px;
      padding: 20px;
      background-color: #fff;
      cursor: pointer;

      .list-info-title {
        font-size: 18px;
        color: #333;
      }

      .list-info-content {
        display: flex;
        justify-content: space-between;
        width: 100%;
        height: 70px;
        margin-top: 10px;
        font-size: 12px;
        color: #8992a9;

        .list-info-info {
        }
      }

      .list-info-time {
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 12px;
        color: #8992a9;
      }

      .list-info-type {
        display: flex;
        align-items: center;
        margin-top: 10px;
        font-size: 14px;
        color: #8992a9;

        .list-info-type-title {
        }

        .list-info-type-value {
          margin: 0;
          margin-left: 10px;
          padding: 2px 6px;
          color: #1d5ede;
          background: #eff4ff;
        }
      }
    }
  }

  .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
  }
}
</style>
